package io.gitee.minelx.filesystem.hdfs.provider;

import io.gitee.minelx.filesystem.provider.FS;
import io.gitee.minelx.filesystem.provider.PathMethodProvider;
import io.gitee.minelx.filesystem.values.PathDescription;
import org.apache.hadoop.fs.FileSystem;

public class HDFS implements FS {
	private final FileSystem fileSystem;

	private final short replicationOfFileBeingCreated;

	private HDFS(FileSystem fileSystem, short replicationOfFileBeingCreated) {
		this.fileSystem = fileSystem;
		this.replicationOfFileBeingCreated = replicationOfFileBeingCreated;
	}

	@Override
	public PathMethodProvider provider(PathDescription description) {
		return new HDFSPathMethodProvider(fileSystem, schemaAndAuthority(), description, replicationOfFileBeingCreated);
	}

	@Override
	public String schemaAndAuthority() {
		return fileSystem.getUri().toString();
	}

	public static HDFS create(FileSystem fileSystem, short replicationOfFileBeingCreated) {
		return new HDFS(fileSystem, replicationOfFileBeingCreated);
	}
}
